<template>
    <view class="page_root" data-page-name="任务列表(3)" data-page-identification="i_f546ooxwfw">
        <!-- UNI_APP_EXEGESIS_START NAVIGATION_TEMPLATE UNI_APP_EXEGESIS_END -->
        <!-- begin vid_z2zwbzlow4 自定义模板_923j1t5i2v -->
        <view class="body">
            <view class="content">上月项目绩效平均分数</view>
            <view class="message">{{  }}</view>
            <view class="content">上月员工绩效平均分数</view>
            <view class="message">{{ }}</view>
            <view class="content">上个月员工工时平均分数</view>
            <view class="message"></view>
            <view class="content">各项目上月绩效分数排行</view>
            <view class="message"></view>
            <view class="content">各项目上月关联任务完成率排行</view>
            <view class="message"></view>
        </view>
        <!-- end vid_z2zwbzlow4 自定义模板_923j1t5i2v -->
    </view>
</template>
<script setup>

import {
    ref, reactive, toRaw, markRaw,
    watch, computed,
    onBeforeMount, onMounted, onBeforeUnmount, onUnmounted, onActivated, onDeactivated, getCurrentInstance
} from "vue";
import { useRoute } from 'vue-router';
const route = useRoute();
import { get, post, put, del, request, requestWithHeaders } from '@/utils/http/Axios';
import { cloneDeep, localGet, traversalTreeStructure, set, checkCaseCondition, throttle, merge, debounce, getGridStyle, getCellRenderAble, formulaStrategy } from '@/utils/index';
import { isEqual, isNullOrEmpty, isEmptyArr, isArray, isEmpty, isNullOrUnDef, isContained } from '@/utils/is';
import { CovertOptions, getChartsDataSourceConvert } from '@/utils/chart';
import { propertyFormatByNumber, propertyFormatByPercentage, propertyFormatByDate } from '@/utils/format';
import { FormFormat } from '@/utils/formFormat'
import { customAddWaterMarkFunc, generateWaterMarkText } from '@/utils/addWaterMark';
import dayjs from 'dayjs';
import hashSum from 'hash-sum';
/*** UNI_APP_EXEGESIS ***
import { handleRedirect, permission, parseJson } from '@/utils/common';
import { onPullDownRefresh, onLoad, onReady, onShow, onHide, onPageScroll, onUnload } from '@dcloudio/uni-app';
import { BroadcastMessage } from '@/utils/BroadcastMessage';
import { sendToken } from "@/hooks/useIframeToken";
*** UNI_APP_EXEGESIS ***/


// ---------------------------- 属性定义 ----------------------------
const sourceId = "page3000000286"

// 是否显示菜单按钮
const isMenuIconShow = false;
// NAVIGATION_MENU
const handleShowNavigation = () => { };

let isProcessState = ref(false);


const setTimeOutList = [];


const vid_z2zwbzlow4_props = reactive({
    code: "",
});



// ============================ 属性定义 ============================

// ---------------------------- 元素数据引用 ----------------------------
// 组件 自定义模板_923j1t5i2v ref 的引用
const vid_z2zwbzlow4_ref = ref(null);
// 动态key的map
const fieldTypeMap = {};
// 动态key的map
const refMap = { vid_z2zwbzlow4_ref };

const showState = reactive({
    vid_z2zwbzlow4_visible: true,
})
// ============================ 元素数据引用 ============================

// ---------------------------- 数据 ----------------------------


// ============================ 数据 ============================

// ---------------------------- 方法 ----------------------------
// ---------------------------- 页面数据 ----------------------------


// ============================ 页面数据 ============================

// ---------------------------- 响应 ----------------------------

// ============================ 响应 ============================

// ---------------------------- 函数 ----------------------------

// 自定义函数 返回上一页
const customFunction_goBack_ksoncqsz03 = (...params) => {
    uni.navigateBack()
}

// ============================ 函数 ============================

// ---------------------------- 页面参数 ----------------------------

const pageParameter_state = reactive({
    'processInstanceId': undefined,
})

// ============================ 页面参数 ============================

// ---------------------------- 组件事件处理方法 ----------------------------


// ============================ 组件事件处理方法 ============================

// ============================ 方法 ============================

// ---------------------------- 生命周期 ----------------------------
/*** UNI_APP_EXEGESIS ***
    // 获取上一层传递的数据
    const workflowChannel = new BroadcastMessage('WORKFLOW');
    workflowChannel.publish({ status: 'Ready' });
    workflowChannel.subscribe((data) => {
      if (data) {
        isProcessState.value = (window.self !== window.parent && data.type === 'hideHeader');
      }
    });
    *** UNI_APP_EXEGESIS ***/


const pageScrollTop = ref(0)

// *** PREVIEW_EXEGESIS ***
onMounted(() => {
    setPageParams(route.query)
    // 设置表单的rule
    try {

    } catch {
        // do nothing
    }
});
// *** PREVIEW_EXEGESIS *** //

/*** UNI_APP_EXEGESIS ***
const routeOption = ref({})
onLoad((option) => {
  routeOption.value = option;
});
onReady(() => {
  setPageParams(routeOption.value)
  // 设置表单的rule
  try{
 
  }catch{
      // do nothing
  }
});
// 图表刷新标记
const uChartsReshowFlag = ref(false);
onHide(() => { // 页面隐藏后标记置为false(如果不置为false无法触发图表更新)
    uChartsReshowFlag.value = false
})
onShow(() => {
    uChartsReshowFlag.value = true; // 页面激活后,标记置为true
 
    setPageParams(routeOption.value)
})
onPageScroll(e => {
    pageScrollTop.value = e.scrollTop
});
*** UNI_APP_EXEGESIS ***/

const setPageParams = (routerParam) => {
    const pageParams = [{ "dataType": "STRING", "dependencies": [], "name": "processInstanceId" }];
    const strategyMap = {
        STRING: (param, paramValue) => {
            pageParameter_state[param.name] = paramValue;
        },
        BOOLEAN: (param, paramValue) => {
            if ('true' === (paramValue || '').toLowerCase()) {
                pageParameter_state[param.name] = true
            } else if ('false' === (paramValue || '').toLowerCase()) {
                pageParameter_state[param.name] = false
            } else {
                // TODO: 是否要支持toast
                console.error('参数传入错误！类型不匹配！');
            }
        },
        NUMBER: (param, paramValue) => {
            if (!isNaN(paramValue)) {
                pageParameter_state[param.name] = Number(paramValue);
            } else {
                // TODO: 是否要支持toast
                console.error('参数传入错误！类型不匹配！');
            }
        },
        ARRAY: (param, paramValue) => {
            if (isNullOrUnDef(paramValue) || !paramValue || paramValue === 'undefined') { // default value
                pageParameter_state[param.name] = [];
            } else if (paramValue.trim().startsWith('[') && paramValue.trim().endsWith(']')) {
                try {
                    pageParameter_state[param.name] = JSON.parse(decodeURI(paramValue));
                } catch (error) {
                    console.error('参数解析失败 ', error);
                }
            } else {
                console.error('参数传入错误！类型不匹配！');
            }
        },
    };
    pageParams.forEach((param) => {
        strategyMap[param.dataType](param, routerParam[param.name])
    });


}

onUnmounted(() => {
    // 销毁定时器
    setTimeOutList.forEach(({ repeat, timer }) => {
        repeat ? clearInterval(timer) : clearTimeout(timer);
    });
});


/*** UNI_APP_EXEGESIS ***
onPullDownRefresh(() => {
  // 下拉刷新
  setTimeout(() => {
      uni.stopPullDownRefresh()
  }, 1000)
})
*** UNI_APP_EXEGESIS ***/

// ============================ 生命周期 ============================

// ---------------------------- 数据关联处理 ----------------------------
// ---------------------------- 组件数据同步 ----------------------------

// ============================ 组件数据同步 ============================
//
// ============================ 数据关联处理 ============================

// ---------------------- 不同组件自定义的处理逻辑 ---------------------

// ====================== 不同组件自定义的处理逻辑 ======================


// ================================定制化逻辑========================================
post('/solution-ppm/api/v2/built-in-system-ppm/dashboard/performance/project_info/search').then(({ data }) => {
    let deliverList = [];
    let marketList = [];
    let productList = [];
    data.forEach(project => {
        if (project.projectType === '交付') {
            deliverList.push(project);
        } else if (project.projectType === '市场') {
            marketList.push(project);
        } else if (project.projectType === '产品研发') {
            productList.push(project);
        }
    });
    deliverList = deliverList.map(item => convertCamelToUnderscore(item));
    marketList = marketList.map(item => convertCamelToUnderscore(item));
    productList = productList.map(item => convertCamelToUnderscore(item));
// 交付for循环
// blockPropState['vid_rk806jurtu_props']['dataSets']['source'] = deliverList
// // 平台for循环
// blockPropState['vid_59o5dpyii8_props']['dataSets']['source'] = productList
// // 市场for循环
// blockPropState['vid_nplhhqvz61_props']['dataSets']['source'] = marketList
console.log(deliverList,'交付')
    console.log(productList,'产品')
    console.log(marketList,'市场')
})
function convertCamelToUnderscore(obj) {
    const result = {};
    for (const key in obj) {
        if (obj.hasOwnProperty(key)) {
            const newKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
            result[newKey] = obj[key];
        }
    }
    return result;
}

</script>
<style lang="less" scoped>
.page_root {
    min-height: 100%;
    box-sizing: border-box;
}

.message {
    width: 100%;
    height: 200px;
    background-color: #d9d9d9;
}
</style>
  